home *** CD-ROM | disk | FTP | other *** search
- unit IniMod;
- interface
- uses
- SysUtils, Classes;
-
- type
- ELoginFailed = class(Exception);
-
- procedure GetLines(const User, Passw: String;
- Lines: TStrings); // raises ELoginFailed
-
- procedure SetLines(const User,Passw: String;
- Lines: TStrings); // raises ELoginFailed
-
- implementation
- uses
- IniFiles;
-
- var
- IniFile: TIniFile = nil;
-
- procedure GetLines(const User,Passw: String; Lines: TStrings);
- var
- i: Integer;
- begin
- if (User <> '') and
- (IniFile.ReadString(User,'password','') = Passw) then
- begin
- Lines.Clear;
- for i:=1 to IniFile.ReadInteger(User,'lines',0) do
- Lines.Add(IniFile.ReadString(User,IntToStr(i),''))
- end
- else
- raise ELoginFailed.Create('Login failed.')
- end {GetLines};
-
- procedure SetLines(const User,Passw: String; Lines: TStrings);
- var
- i: Integer;
- begin
- if (User <> '') and
- (IniFile.ReadString(User,'password','') = Passw) then
- begin
- IniFile.EraseSection(User);
- IniFile.WriteString(User,'password',Passw); { reset password }
- IniFile.WriteInteger(User,'lines',Lines.Count); { linescount }
- for i:=1 to Lines.Count do
- IniFile.WriteString(User,IntToStr(i),Lines[Pred(i)])
- end
- else
- raise ELoginFailed.Create('Permission denied.')
- end {SetLines};
-
- initialization
- IniFile := TIniFile.Create('.\BobNotes.ini');
- finalization
- IniFile.Free;
- IniFile := nil
- end.
-